#coding: utf-8
from django.forms import widgets,ModelForm
from django import forms
from .models import Article,Category,Tag,Link
from ckeditor_uploader.widgets import CKEditorUploadingWidget

class ArticleForm(ModelForm):
    class Meta:
        model = Article
        exclude = ['author', 'views', 'slug', 'pub_date', 'users_like'] #排除的字段
        widgets = {
            'title': forms.TextInput(attrs={'class': 'form-control'}),
            'body': CKEditorUploadingWidget(attrs={'class': 'form-control'}),
            'status': forms.Select(attrs={'class': 'form-control'}),
            'category': forms.Select(attrs={'class': 'form-control'}),
            'tags': forms.CheckboxSelectMultiple(attrs={'class': 'multi-checkbox'}),
        }

class CategoryForm(ModelForm):
    class Meta:
        model = Category
        exclude = ['slug']
        widgets = {
            'name': forms.TextInput(attrs={'class': 'form-control'}),
            'parent_category': forms.Select(attrs={'class': 'form-control'}),
        }


class TagForm(ModelForm):
    class Meta:
        model = Tag
        exclude = ['slug']
        widgets = {
            'name': forms.TextInput(attrs={'class': 'form-control'}),

        }